package com.dbh.jdk.concurrent;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 *  计算两个数的商示例
 *
 * @author dongbanghui
 * @date 2018/06/06
 */
public class DivTask implements Runnable {

    int a,b;

    public DivTask(int a, int b){
        this.a = a;
        this.b = b;
    }

    @Override
    public void run() {
        double re = a/b;
        System.out.println(re);
    }

    public static void main(String[] args) {
        ThreadPoolExecutor pools = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 0L, TimeUnit.MILLISECONDS,
                new SynchronousQueue<>());
        for(int i=0;i<5;i++){
            pools.execute(new DivTask(100, i));
        }
    }

    /*public static void main(String[] args) {
        TraceThreadPoolExector pools = new TraceThreadPoolExector(0, Integer.MAX_VALUE, 0L, TimeUnit.MILLISECONDS,
                new SynchronousQueue<>());
        for(int i=0;i<5;i++){
            pools.execute(new DivTask(100,i));
        }
    }*/
}
